# api/v1/wcs/schemas.py
from pydantic import BaseModel, Field
from typing import List

# ========= request schemas =========
# WCS Mix Task Schema
class RequestMixTaskDescription(BaseModel):
    """定义任务详情"""
    task_type: int = Field(..., examples=[0,1,2], description="任务类型: 0-入库 1-出货 2-库内转移")
    start_or_gate_location: str = Field(..., examples=["1,1,1"], description="货物起点坐标或者出入口坐标 (格式: 'wh,x,y' - '库区,层,列')")
    target_location: str = Field(..., examples=["1,4,4"], description="货物目标坐标 (格式: 'wh,x,y' - '库区,层,列')")

class RequestMixTask(BaseModel):
    """定义单个任务的模型"""
    task_no: str = Field(..., examples=["T222_1"], description="任务号")
    description: List[RequestMixTaskDescription] = Field(..., description="任务详情")

class RequestMixTaskList(BaseModel):
    """定义整个请求体的模型"""
    stacker_location: str = Field(..., examples=["0,1,1"], description="堆垛机位置  (格式: '0,x,y' - '0,层,列') 堆垛机始终使用0代表库区")
    tasks: List[RequestMixTask] = Field(..., description="任务列表")


# ========= response schemas =========
class ResponseMixTask(BaseModel):
    """定义任务响应体"""
    task_no: str = Field(..., examples=["T222_1"], description="任务号")
    task_type: int = Field(..., examples=[0], description="任务类型 (0-入库 1-出货 2-库内转移)")
    path_1: List = Field(..., examples=[[1, "1,2,3", "1,1,1"]], description="路径1 - [动作，起点，终点]")
    path_2: List = Field(..., examples=[[2, "1,1,1", "1,4,4"]], description="路径2 - [动作，起点，终点]")
    end_location: str = Field(..., examples=["1,4,4"], description="最后位置")

class ResponseMixTaskList(BaseModel):
    """定义任务响应体"""
    message: str = Field(..., examples=["数据接收成功"], description="响应消息")
    total_tasks_received: int =  Field(..., examples=[1], description="接收的任务总数")
    data: List[ResponseMixTask] = Field(..., description="处理后的任务数据")